//
//  LGCiTangFamilyTreeViewController.m
//  ligenyun
//
//  Created by Mac on 2018/3/26.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGCiTangFamilyTreeViewController.h"
#import "LGCiTangFamilyTreeHeader.h"
#import "LGCiTangCreateFamilyTreeController.h"
#import "LGCiTangCreateBiographyController.h"
#import "LGCiTangMineZuPuViewController.h"
@interface LGCiTangFamilyTreeViewController ()
@property(nonatomic, strong) LGCiTangFamilyTreeHeader                     *header;
@property(nonatomic, strong) NSArray                     *dataSouce;
@end

@implementation LGCiTangFamilyTreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"族谱";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    __weak typeof(self) weakSelf =  self;
    self.header = [[LGCiTangFamilyTreeHeader alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 30)];
    [self.header setOnSelctedMenuButton:^(NSString *title) {
        [weakSelf onSelctedHeaderWithTitle:title];
    }];
    self.tableView.tableHeaderView = self.header;
    
    self.dataSouce = @[
                       [[STTableEasyModel alloc] initWithTextString:@"联系人:赵姐" detailString:@""],
                       [[STTableEasyModel alloc] initWithTextString:@"电话：18380461887" detailString:@""],
                       [[STTableEasyModel alloc] initWithTextString:@"地址：车鞥都市打" detailString:@""],
                       [[STTableEasyModel alloc] initWithTextString:@"创建时间：2018-03-26 14:08:28" detailString:@""],
                       [[STTableEasyModel alloc] initWithTextString:@"本谱权限:族谱卡课可见" detailString:@""],
                       [[STTableEasyModel alloc] initWithTextString:@"简介:" detailString:@""]
                       ];
    [self.tableView reloadData];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1    ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSouce.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    STTableEasyModel * model = self.dataSouce[indexPath.row];
    [cell setSt_tableEasyModel:model];
    cell.accessoryType = UITableViewCellAccessoryNone;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark --Action Method
- (void)onSelctedHeaderWithTitle:(NSString*)title{
    if ([title isEqualToString:@"编辑谱书"]) {
        [self.navigationController pushViewController:[LGCiTangCreateFamilyTreeController new] animated:YES];
    }
    if ([title isEqualToString:@"族谱传记"]) {
         [self.navigationController pushViewController:[LGCiTangCreateBiographyController new] animated:YES];
        
    }
    if ([title isEqualToString:@"查看谱书"]) {
         [self.navigationController pushViewController:[LGCiTangMineZuPuViewController new] animated:YES];
    }
    if ([title isEqualToString:@"宗教祠堂"]) {
        UIViewController * vc = self.navigationController.childViewControllers[1];
        [self.navigationController popToViewController:vc animated:YES];
    }
    if ([title isEqualToString:@"地理位置"]) {
         [self.navigationController pushViewController:[LGCiTangMineZuPuViewController new] animated:YES];
    }
}
@end
